﻿@model PagedList<ADZ_SupplierDetails>
@{
    ViewBag.Title = "收款账户列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    SupplierDetailListQueryModel paramModel = new SupplierDetailListQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (SupplierDetailListQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("payaccountlist", "supplier")" method="get">
    <div class="form_query">
        <div>
            供应商名称：
            <input type="text" name="supplier_name" id="supplier_name" class="abc input-default" placeholder="" value="@paramModel.supplier_name">&nbsp;
        </div>
        <div>
            审核状态：
            <select id="audit_status" name="audit_status">
                <option value="-10">全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add("0", "未审核");
                    dc.Add("1", "已审核");
                    dc.Add("2", "已驳回");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.audit_status.ToString());
            </select>&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
            <button type="button" class="btn btn-success" id="btnadd" onclick="document.location='@Url.Action("addpayaccount","supplier")'">新增</button>
        </div>
    </div>
</form>

<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>编号</th>
            <th>供应商名称</th>
            <th>收款渠道</th>
            <th>货币种类</th>
            <th>公私账户</th>
            <th>是否开票</th>
            <th>收款详情</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td>@m.seq_id</td>
                <td>
                    @{
                        var master = dbcontext.ADZ_SupplierMaster.FirstOrDefault(t => t.supplier_id == m.supplier_id);
                        if (master != null)
                        {
                            <info>
                                @master.supplier_name
                            </info>
                        }
                    }
                </td>
                <td>
                    @(YiYiTong.Rocket.Helper.EnumHelper.GetEnumItemDescription<SupplierPayChanner>(m.channel))
                </td>
                <td>
                    @(YiYiTong.Rocket.Helper.EnumHelper.GetEnumItemDescription<CurrencyType>(m.currency_type))
                </td>
                <td>
                    @(YiYiTong.Rocket.Helper.EnumHelper.GetEnumItemDescription<bank_acc_type>(m.bank_acc_type))
                </td>
                <td>
                    @(YiYiTong.Rocket.Helper.EnumHelper.GetEnumItemDescription<is_invoice>(m.is_invoice))
                </td>
                <td>
                    @{
                        if (m.channel == (int)SupplierPayChanner.Bank)
                        {
                            <info>
                                银行名：@m.bank_name @m.branch_bank_name 开户名：@m.bank_account_name 银行账号：@m.bank_account
                            </info>
                        }
                        if (m.channel == (int)SupplierPayChanner.Alipay)
                        {
                            <info>
                                支付宝账号：@m.alipay_account
                            </info>
                        }
                        if (m.channel == (int)SupplierPayChanner.Weixin)
                        {
                            <info>
                                微信账号：@m.wechat_account
                            </info>
                        }
                    }
                </td>
                <td>
                    @(YiYiTong.Rocket.Helper.EnumHelper.GetEnumItemDescription<AuditStatus>(m.audit_status))
                </td>
                <td>
                    @if (string.IsNullOrEmpty(@ViewData["mg_supplier_name"] == null ? "" : @ViewData["mg_supplier_name"].ToString()))
                    {
                        if (m.audit_status == (int)AuditStatus.Create)
                        {
                            <a href="javascript:void(0);" onclick="toAudit(@m.seq_id)">审核</a>
                            <a href="javascript:void(0);" onclick="toGiveBack(@m.seq_id)">驳回</a>

                        }
                        <a href="javascript:void(0);" onclick="toDel(@m.seq_id)">删除</a>
                    }
                    @if (m.audit_status != (int)AuditStatus.AuditSucc)
                    {
                        <a href="@Url.Action("editpayaccount", "supplier", new { id = m.seq_id})">编辑</a>
                    }
                </td>
            </tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    reloadHandler = function () {
        window.location.reload();
    }

    $(function () {
        var mg_supplier_name = '@ViewData["mg_supplier_name"]';
        if (mg_supplier_name != null && mg_supplier_name != '') {
            //禁止选择
　　          $("#supplier_name").attr("disabled","disabled");
            $("input[name='supplier_name']").val(mg_supplier_name);
        }
    });
    function toDel(id) {
         BUI.Message.Show({
            title: '提示',
            msg: '确定要删除该收款账户信息吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("ToDelPayAccount", "supplier")";
                        parameter = { id: id };
                        $.post(url, parameter, function (result) {
                            ShowActionResult(result, reloadHandler);
                    });
                    this.close();
                 }
              },
              {
                 text: '取消',
                  elCls: 'button',
                  handler: function () {
                      this.close();
                  }
              }

            ]
        });
        }

    function toAudit(id) {
         BUI.Message.Show({
            title: '提示',
            msg: '确定要审核通过该收款账户信息吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("toAudit", "supplier")";
                        parameter = { id: id };
                        $.post(url, parameter, function (result) {
                            ShowActionResult(result, reloadHandler);
                    });
                    this.close();
                 }
              },
              {
                 text: '取消',
                  elCls: 'button',
                  handler: function () {
                      this.close();
                  }
              }

            ]
        });
        }

    function toGiveBack(id) {
         BUI.Message.Show({
            title: '提示',
            msg: '确定要驳回该收款账户信息吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("toGiveBack", "supplier")";
                        parameter = { id: id };
                        $.post(url, parameter, function (result) {
                            ShowActionResult(result, reloadHandler);
                    });
                    this.close();
                 }
              },
              {
                 text: '取消',
                  elCls: 'button',
                  handler: function () {
                      this.close();
                  }
              }

            ]
        });
    }
</script>

